/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cse308.entities;

import cse308.GeneralEntity;
import cse308.helper_classes.GeneralTest;
import java.io.Serializable;
import java.util.List;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Aaron
 */
@Entity
@Table(catalog = "nchorn", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Altcoursecoordinators.findAll", query = "SELECT a FROM Altcoursecoordinators a"),
    @NamedQuery(name = "Altcoursecoordinators.findByCourseidentifier", query = "SELECT a FROM Altcoursecoordinators a WHERE a.altcoursecoordinatorsPK.courseidentifier = :courseidentifier"),
    @NamedQuery(name = "Altcoursecoordinators.findByAltcoordinator", query = "SELECT a FROM Altcoursecoordinators a WHERE a.altcoursecoordinatorsPK.altcoordinator = :altcoordinator")})
public class Altcoursecoordinators implements Serializable, GeneralEntity {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected AltcoursecoordinatorsPK altcoursecoordinatorsPK;
    @JoinColumn(name = "courseidentifier", referencedColumnName = "identifier", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Courseinfo courseinfo;

    public Altcoursecoordinators() {
    }

    public Altcoursecoordinators(AltcoursecoordinatorsPK altcoursecoordinatorsPK) {
        this.altcoursecoordinatorsPK = altcoursecoordinatorsPK;
    }

    public Altcoursecoordinators(String courseidentifier, String altcoordinator) {
        this.altcoursecoordinatorsPK = new AltcoursecoordinatorsPK(courseidentifier, altcoordinator);
    }

    public AltcoursecoordinatorsPK getAltcoursecoordinatorsPK() {
        return altcoursecoordinatorsPK;
    }

    public void setAltcoursecoordinatorsPK(AltcoursecoordinatorsPK altcoursecoordinatorsPK) {
        this.altcoursecoordinatorsPK = altcoursecoordinatorsPK;
    }

    public Courseinfo getCourseinfo() {
        return courseinfo;
    }

    public void setCourseinfo(Courseinfo courseinfo) {
        this.courseinfo = courseinfo;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (altcoursecoordinatorsPK != null ? altcoursecoordinatorsPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Altcoursecoordinators)) {
            return false;
        }
        Altcoursecoordinators other = (Altcoursecoordinators) object;
        if ((this.altcoursecoordinatorsPK == null && other.altcoursecoordinatorsPK != null) || (this.altcoursecoordinatorsPK != null && !this.altcoursecoordinatorsPK.equals(other.altcoursecoordinatorsPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "cse308.entities.Altcoursecoordinators[ altcoursecoordinatorsPK=" + altcoursecoordinatorsPK + " ]";
    }
     @Override
    public List<List<GeneralEntity>> getAssociatedClasses() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public List<GeneralEntity> getAssociatedClass(String associated) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public void setWithClass(GeneralTest gt) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public void testAddClass(GeneralEntity ge) {
        if(ge instanceof Courseinfo){
            this.courseinfo=(Courseinfo)ge;
        }
    }

    @Override
    public void removeClass(GeneralEntity ge) {
        if(ge instanceof Courseinfo){
            this.courseinfo=null;
        }
    }

    @Override
    public GeneralEntity findCorrespondingEntity() {
        return this;
    }

    @Override
    public String getIdentifier2() {
        return this.altcoursecoordinatorsPK.getAltcoordinator()+" "+this.altcoursecoordinatorsPK.getCourseidentifier();
    }

    @Override
    public boolean equalsEntity(GeneralEntity entity) {
        return this.equals(entity);
    }

    @Override
    public Object getPK() {
        return this.altcoursecoordinatorsPK;
    }


}
